import { reactive } from 'vue'

export default ()=>{
    const state = reactive({
        verifyText:'获取验证码',
        disabled:false
    })
    let timer:any = null
    let time = 60
    const getSmsCode = ()=>{
        if(timer)return
        state.disabled = true
        timer = setInterval(()=>{
            state.verifyText = time +'s'
            if(time>0){
                time--
            }else{
                state.disabled = false
                state.verifyText = '获取验证码'
                clearInterval(timer)
                timer = null
            }
        },1000)
    }
    return {state,getSmsCode}
}
